<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->hostInfo; ?>/css/customize.css?v=<?php echo Yii::app()->params['version']['CSS'];?>"/>
<!--广告图片-->
<?php $this->beginWidget('application.widget.adver.banner', array('bannerId'=>3)); ?>
<?php $this->endWidget(); ?>
<div class="customize">
    <div class="mask"></div>
	<div class="wrap">
    	<div class="info">
        	<img class="qr" src="<?php echo Yii::app()->request->hostInfo; ?>/images/customize/qrcode.jpg?v=<?php echo Yii::app()->params['version']['IMG'];?>" alt="" />
        	<dl>
        		<dt>最随时随地的方法</dt>
        		<dd>用手机扫一扫二维码</dd>
        		<dd>任何时间，任何地点</dd>
        		<dd>告诉我们你已经做好了出发的决定</dd>
        	</dl>
            <div class="other">
            	<!--<a href="javascript:void(0);" class="wx"></a>-->
            	<a href="javascript:<?php echo Yii::app()->params['qqContant'];?>;" class="qq"></a>
            	<a href="<?php echo Yii::app()->params['weiboUrl'];?>" target="_blank" class="sina"></a>
            </div>
        </div>
        <table border="0" cellspacing="0" cellpadding="0">
          <tr>
            <th scope="row">目的地</th>
            <td><p><input type="text" class="t" name="destination"/></p></td>
          </tr>
          <tr>
            <th scope="row">出行人数</th>
            <td><p><input type="text" class="t" name="person_num"/></p></td>
          </tr>
          <tr>
            <th scope="row">出行日期</th>
            <td><p><input type="text" class="t date" id="datepicker" readonly="readonly" value="<?php echo date("Y-m-d",strtotime("+3 day"));?>" name="start_time"/></p></td>
          </tr>
          <tr>
            <th scope="row">联系方式</th>
            <td><p><input type="text" class="t" id="" name="contant"/></p></td>
          </tr>
          <tr>
            <th scope="row"></th>
            <td><a href="javascript:void(0);" id="submit">提交</a><span>* 花几秒钟，我们会安排最合适的定制旅行师与你联系</span></td>
          </tr>
        </table>
    </div>
</div>
<script type="text/javascript" src="<?php echo Yii::app()->request->hostInfo; ?>/assets/js/pikaday.js?v=<?php echo Yii::app()->params['version']['JS'];?>"></script>
<script type="text/javascript">
$(".customize .mask").css({"opacity":0.4});
var picker = new Pikaday({
	field: document.getElementById('datepicker'),
	firstDay: 1,
	minDate: new Date('2000-01-01'),
	maxDate: new Date('2020-12-31'),
	yearRange: [2000,2020]
});

$(function(){
	$("#submit").bind("click", function(){
		var request = {};
		request.url = "<?php echo Yii::app()->createUrl('customize/book');?>";
		request.type = "post";
		request.dataType = "JSON";
		request.data = {};
		request.data.customizeForm = {};
		request.data.customizeForm.destination = $.trim($("input[name=destination]").val());
		if(request.data.customizeForm.destination == ""){
			$.jGrowl("请输入目的地");
			return false;
		}
		request.data.customizeForm.personNum = $.trim($("input[name=person_num]").val());
		if(request.data.customizeForm.personNum == ""){
			$.jGrowl("请输入人数");
			return false;
		}
		request.data.customizeForm.startTime = $.trim($("input[name=start_time]").val());
		if(request.data.customizeForm.startTime == ""){
			$.jGrowl("请输入开始时间");
			return false;
		}
		request.data.customizeForm.contant = $.trim($("input[name=contant]").val());
		if(request.data.customizeForm.contant == ""){
			$.jGrowl("请输入联系方式");
			return false;
		}
		request.error = function(){$.jGrowl("有点问题~")};
		request.complete = function(){$(this).attr("disabled", false);};
		request.success = function(msg){
			//登录
			if(msg.header.status == 10001){
				location.href = msg.body.returnUrl;
				return false;
			}
			//错误提示
			if(msg.header.status != 0){
				$.jGrowl('<h2>咦？提交失败......</h2><p>咿呀，'+msg.header.reqMsg+'，修改后重新提交吧~</p>');
				return false;
			}
			//成功提示
			$.jGrowl('<h2>提交成功！</h2><p>我们“圈养“了一批奔波世界的野生专业规划师，请期待超高性价比的精彩旅程吧！</p>');
			$("input[name=destination]").val("");
			$("input[name=person_num]").val("");
			$("input[name=contant]").val("");
		};
		request.time = 5000;
		$.ajax(request);
	});
	$("input[name=person_num]").on("blur", function(){
		var val = $(this).val();
		val = parseInt(val);
		val = isNaN(val)?1:(val>999?999:val);
		$(this).val(val);
	});
});

</script>